Repository navigation
Use logging in the decommutator and return a DecommutationResult - #87
Merged
Merged
Conversation
Prepare to replace print calls and the hand-rolled log file in the decommutator with the logging module. Each module gets a logger named after it, and the package logger gets a NullHandler so that library use emits nothing unless the application configures logging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Provide one public way to send pyfaradaycup log messages to the console and a log file, usable both from Python and from the command line tool. Handlers are added only to the pyfaradaycup logger, a later call replaces the handlers from an earlier one, and the returned LoggingConfiguration can be closed or used in a with block. Log file timestamps are in UTC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Library code should only create loggers, so that applications using pyfaradaycup keep control of where log messages go. Use ruff's banned-api rule so that handlers are configured only in pyfaradaycup._logging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Warnings captured with logging.captureWarnings go to the py.warnings logger rather than the pyfaradaycup logger, so the command line tool needs configure_logging to attach its handlers there too for warnings to reach the console and log file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace print and sys.stdout.write in ccsds_reader_pipeline with logging, so that the reader is silent when used from Python unless logging is configured. Each rejected packet is logged at the DEBUG level with its byte offset, and the number of packets found for each APID and rejected for each reason is logged once at the end, rather than printing one line per packet. The progress display is removed, and the verbose arguments are no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace _statusmsg and the module-level log file in swp_spc_l0_to_l05 with logging, so that main can be called from Python without writing files or printing, and remove its logdir and verbose arguments. The command line tool now configures logging. Its log file name includes the name of the L0 file and a UTC timestamp, and is opened with mode "x" so that runs cannot overwrite each other's logs. The -v/--verbose option can be repeated to print progress (-v) or details (-vv), -q/--quiet prints only errors, and warnings are printed by default. Warnings about options with no effect and captured Python warnings go to the log file too. An unexpected error is logged with its traceback, and the exit code is 1. Messages that were printed for every rejected packet are logged at the DEBUG level and summarized with one warning per APID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record where each conversion's results came from, so that L0.5 CDF files can be traced back to the inputs and software that made them. main now logs the software versions, host, working directory, and the size and SHA-256 checksum of the L0 file, along with the kernels and skeletons it uses, and logs a summary at the end. main returns a DecommutationResult with the CDF files written, the APIDs that could not be converted and why, the packet counts, and the same provenance, so that Python callers such as a Dagster asset do not need to read log output. pfc_decommutator exits with a code of 1 when any APID could not be converted, including APID 0x07B, which is not implemented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
namurphy
commented
Oct 29, 2026
Comment on lines
+235
to
+237
| data directory. A summary of the number of packets found for each | ||
| APID is logged, and the reason each packet was rejected is logged | ||
| at the ``DEBUG`` level. |
Member
Author
There was a problem hiding this comment.
I'm wondering if this level of detail is necessary or would actually be helpful. 🤔
Record follow-up work in the decommutator README: writing provenance into the CDF global attributes, comparing CDF attributes in the end-to-end test, and improvements to the log messages, including tagging records with the L0 file and APID, a JSON Lines format, and logging from more than one process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Napoleon turned the Attributes section into attribute descriptions, and autodoc documented the same dataclass fields again, so a clean documentation build failed with duplicate object warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take the logging implementation and its tests from upstream/main, where configure_logging was merged in PlasmaPy#89, in place of the earlier version on this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
configure_logging from upstream/main accepts "exclusive" rather than "x" for file_mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge took tests/test_logging.py from upstream/main, which does not have the module loggers that this branch adds to the decommutator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
I adjusted the logging levels so that the Note We'll need to come back to the log messages in the future to adjust both the levels of the messages, as well as the content. |
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace the decommutator's hand-rolled log file (
_statusmsgand the module-levellogfile),printcalls, andsys.stdout.writeprogress display with theloggingmodule, usingpyfaradaycup.configure_loggingfrom #89. Also makeswp_spc_l0_to_l05.mainreturn aDecommutationResultand log provenance.ccsds_reader_pipeline,swp_spc_l0_to_l05, andmaineach have their own module logger, so the decommutator is silent from Python unless logging is configured.swp_spc_l0_to_l05.mainno longer takeslogdirorverbose, and no longer writes a log file itself. It logs provenance (software versions, host, working directory, the L0 file's size and SHA-256 checksum, and the kernels and skeletons used) and a summary.mainreturns a frozenDecommutationResultdataclass with the CDF files written, the APIDs that failed and why, packet counts, the same provenance, and the elapsed time.result.succeededisFalseif any APID failed.pfc_decommutatorcallsconfigure_logging:-vprints progress,-vvprints details, and-qprints only errors. Warnings are printed by default, and-vwith-qis a usage error.swp_spc_l0_to_l05_0523462910_4_EA_20261029T190014Z.log. It is opened withfile_mode="exclusive", so runs cannot overwrite each other's logs.DEBUGwith its byte offset, and the reader logs one summary of packets found per APID and rejections per reason. Theverbosearguments of the private reader and CDF writer functions are removed.Motivation
The decommutator will have both a Python API and a CLI, and will run in a Dagster pipeline. It needs to:
This addresses "Return what was written", "Give each run its own log file name", and the
loggingpart of "Make it callable from Python" in the decommutator README.Details
Behavior changes for reviewers to check:
--spacecraft. Previously these runs exited with 0.mainno longer acceptslogdirorverboseand now returns aDecommutationResultinstead ofNone, and the private reader and CDF writer functions no longer acceptverbose.ERROR(one was previously a warning). Per-packet IT+ST and APID 0x352 problems are nowDEBUGmessages, plus oneWARNINGsummary per APID.% Complete) has been removed.Not done here:
warnings.warnin_parse_ccsds_headis unchanged.--spacecraft) path still has no end-to-end test.Tests cover packet rejection logging and the packet summary, the CLI's log file and its contents, exit codes for an unexpected error and a failed APID,
-v/-q, the console level for each verbosity, the warnings about ineffective options, a Python API run that checks the returned result and that nothing is printed, and that each decommutator module has its own logger.🤖 Generated with Claude Code